package com.avengers.core.model.generator;

import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.generator.BaseModelGenerator;
import com.jfinal.plugin.activerecord.generator.TableMeta;

/**
 * @author yu.wang
 * @since 2018-04-05 下午3:45
 */
public class AvengersBaseModelGenerator extends BaseModelGenerator {

    private final String modelPackageName;
    private String baseModelName;
    private String baseModelImport;

    public AvengersBaseModelGenerator(String modelPackageName, String baseModelPackageName, String baseModelOutputDir) {
        super(baseModelPackageName, baseModelOutputDir);
        this.modelPackageName = modelPackageName;
    }

    @Override
    protected void genBaseModelContent(TableMeta tableMeta) {
        Kv data = Kv.by("baseModelPackageName", baseModelPackageName);
        data.set("modelPackageName", modelPackageName);
        data.set("generateChainSetter", generateChainSetter);
        data.set("tableMeta", tableMeta);
        data.set("baseModelName", baseModelName);
        data.set("baseModelImport", baseModelImport);

        tableMeta.baseModelContent = this.engine.getTemplate(template).renderToString(data);
    }

    public String getBaseModelName() {
        return baseModelName;
    }

    public void setBaseModelName(String baseModelName) {
        this.baseModelName = baseModelName;
    }

    public String getBaseModelImport() {
        return baseModelImport;
    }

    public void setBaseModelImport(String baseModelImport) {
        this.baseModelImport = baseModelImport;
    }
}
